package com.santiao.youxiang.database

import org.litepal.LitePal
import org.litepal.annotation.Column
import org.litepal.crud.LitePalSupport

//import androidx.room.Entity
//import androidx.room.PrimaryKey

//@Entity(tableName = "favour_table")


//data class habitTimeLine(
////    @Column( defaultValue = "unknown")  val userId: String="136", // 主键，自动生成 自增id 开屏右下角的id
//    var id: Long = 0L,
//
//
//      var date: String?, //打卡日期
//    var detail: ArrayList<Detail?>?,
//
//
////    var last_token_time: String? //上次token获取的时间
//) :  LitePalSupport(){
//    data class Detail(
//        var habitName: String?,
//        var habitType: String?="0",//图片类型
//        var dateTime: String?,
//        var describe: String?="",/*打卡描述*/
//    )
//}



// 将 Detail 类提升为顶级类

data class Detail(
    @Column
    var habitName: String? = null,
    @Column
    var habitType: String? = "0",
    @Column
    var dateTime: String? = null,
    @Column
    var describe: String? = "",
    @Column
    var timelineId: Long = 0, // 外键关联
    @Column
var habitid: Long = 0 // 外键关联
) : LitePalSupport()



data class habitTimeLine(

    var id: Long = 0,
    @Column
    var date: String? = null,
    @Column
var habitTimeId: Long = 0 // 外键关联
) : LitePalSupport() {
    // 提供便捷方法获取关联的详情
    fun getDetails(): List<Detail> {
        return LitePal.where("timelineId = ?", id.toString())
            .find(Detail::class.java)
    }
}